import pygame, random

IMAGE_PATH = "D:\\MyLinux\\Ubuntu\\Sharedfiles\\6temp\\python-learning\\Airplanewar\\res\\"

# 自定义一个地图类
class GameMap(object):

    def __init__(self, mapWidth = 512, mapHeight = 768):
        self.imgNum = str(random.randint(1, 5))
        self.width = mapWidth
        self.height = mapHeight
        # 打开两张一样的图片图片用来做移动效果
        self.img_1 = pygame.image.load(IMAGE_PATH + "img_bg_level_" + self.imgNum + ".jpg")
        self.img_2 = pygame.image.load(IMAGE_PATH + "img_bg_level_" + self.imgNum + ".jpg")
        # 设置和记录图片的y轴
        self.img1_y = 0
        self.img2_y = -self.height
        
        # 速度
        self.speed = 0.1

    # 向下移动
    def move_down(self):
        # 地图的y轴重置
        if self.img2_y >= 0:
            self.img1_y = 0
            self.img2_y = -self.height
        
        self.img1_y += self.speed
        self.img2_y += self.speed
